class SRVetJuggernaut extends SRVeterancy
	abstract;

static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
{
	switch( CurLevel )
	{
	case 0:
		if( ReqNum==0 )
			FinalInt = 0;
		else FinalInt = 0;
		break;
	case 1:
		if( ReqNum==0 )
			FinalInt = 10000; //
		else FinalInt = 500000; // 0.5M
		break;
	case 2:
		if( ReqNum==0 )
			FinalInt = 32000; //
		else FinalInt = 1500000; // 1M
		break;
	case 3:
		if( ReqNum==0 )
			FinalInt = 64000; //
		else FinalInt = 3500000; // 2M
		break;
	case 4:
		if( ReqNum==0 )
			FinalInt = 107000; //
		else FinalInt = 6000000; // 2.5M
		break;
	case 5:
		if( ReqNum==0 )
			FinalInt = 176000; //
		else FinalInt = 10000000; // 4M
		break;
	case 6:
		if( ReqNum==0 )
			FinalInt = 350000; //
		else FinalInt = 17000000; // 7M
		break;
	case 7:
		if( ReqNum==0 )
			FinalInt = 620000; //
		else FinalInt = 27000000; // 10M
		break;
	case 8:
		if( ReqNum==0 )
			FinalInt = 1000000; //
		else FinalInt = 40000000; // 13M
		break;
	default:
		if( ReqNum==0 )
			FinalInt = 1520000 * ( CurLevel - 8 );
		else FinalInt = 60000000 * ( CurLevel - 8 ); // 20M
	}
	if( ReqNum==0 )
		return Min(StatOther.RWeldingPointsStat,FinalInt);
	return Min(StatOther.RStalkersKilledWithExplosivesStat,FinalInt);
}

static function int AddDamage(KFPlayerReplicationInfo KFPRI, KFMonster Injured, KFPawn DamageTaker, int InDamage, class<DamageType> DmgType)
{	
	/*
	if( class<DamTypeMG>(DmgType) != none )
	{
		return (1.25 + (0.05 * float(Min(9,KFPRI.ClientVeteranSkillLevel)))) * Super.AddDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
	}
	*/
	return Super.AddDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function int ReduceDamage(KFPlayerReplicationInfo KFPRI, KFPawn Injured, KFMonster DamageTaker, int InDamage, class<DamageType> DmgType)
{
	local float FinalDamage,Modifer;

	if ( class<ZombieMeleeDamage>(DmgType) != none )
	{
		Modifer = ( 0.68 - 0.02 * float(Min(KFPRI.ClientVeteranSkillLevel,9)) );
	}
	else
	{
		Modifer = 1.00;
	}
	
	FinalDamage = InDamage;
	FinalDamage *= Modifer;
	FinalDamage += SRHumanPawn(SRPlayerReplicationInfo(KFPRI).Controller.Pawn).IncomingDamageRemainder;
	InDamage = FinalDamage;
	SRHumanPawn(SRPlayerReplicationInfo(KFPRI).Controller.Pawn).IncomingDamageRemainder = FinalDamage - float(InDamage);
	
	Super.ReduceDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function float GetAmmoPickupMod(KFPlayerReplicationInfo KFPRI, KFAmmunition Other)
{
/*
	if( KFPRI.ClientVeteranSkillLevel > 9 )
		return 100.0;
*/
	if ( Frag1Ammo(Other) != None )
		return 0.0;

	if ( ThompsonAmmo(Other) != none && KFPRI.ClientVeteranSkillLevel > 9 )
	{
		return 3.40 * GetProperAmmoPickupAmount(Other);
	}
	if ( ThompsonAmmo(Other) != none || SA80LSWAmmo(Other) != none || PKMAmmo(Other) != none || M249Ammo(Other) != none || BerettaPx4Ammo(Other) != none ||
		DBerettaPx4Ammo(Other) != none || RPK47Ammo(Other) != none || AUG_A1MGAmmo(Other) != none )
		return ( 1.20 + 0.05 * float(Min(9,KFPRI.ClientVeteranSkillLevel)) ) * GetProperAmmoPickupAmount(Other);

	return GetProperAmmoPickupAmount(Other);
}

static function float AddExtraAmmoFor(KFPlayerReplicationInfo KFPRI, Class<Ammunition> AmmoType)
{
	if ( AmmoType == class'ThompsonAmmo' && KFPRI.ClientVeteranSkillLevel > 9 )
	{
		return 3.40 * GetProperAmmoAmount(AmmoType);
	}
	if ( AmmoType == class'FragAmmo' || AmmoType == class'Frag1Ammo' )
	{
		if( KFPRI.ClientVeteranSkillLevel < 2 )
			return GetProperAmmoAmount(AmmoType);
		if( KFPRI.ClientVeteranSkillLevel < 4 )
			return 1.2 * GetProperAmmoAmount(AmmoType); // 10 grenades
		if( KFPRI.ClientVeteranSkillLevel > 3 )
			return ( 1.0 + 0.2 * FMin(KFPRI.ClientVeteranSkillLevel-2,7) ) * GetProperAmmoAmount(AmmoType);
	}


	if ( AmmoType == class'ThompsonAmmo' || AmmoType == class'SA80LSWAmmo' || AmmoType == class'PKMAmmo' || AmmoType == class'M249Ammo' ||
		AmmoType == class'BerettaPx4Ammo' || AmmoType == class'DBerettaPx4Ammo' || AmmoType == class'RPK47Ammo' || AmmoType == class'AUG_A1MGAmmo' )
		return ( 1.20 + 0.05 * float(Min(9,KFPRI.ClientVeteranSkillLevel)) ) * GetProperAmmoAmount(AmmoType);


	return GetProperAmmoAmount(AmmoType);
}

static function float ModifyRecoilSpread(KFPlayerReplicationInfo KFPRI, WeaponFire Other, out float Recoil)
{
	if ( Thompson(Other.Weapon) != none || SA80LSW(Other.Weapon) != none || PKM(Other.Weapon) != none || M249MachineGun(Other.Weapon) != none ||
		BerettaPx4(Other.Weapon) != none || DualBerettaPx4(Other.Weapon) != none || RPK47Machinegun(Other.Weapon) != none ||
		AUG_A1MG(Other.Weapon) != none )
	{
		Recoil = 0.80 - 0.05 * float(Min(9,KFPRI.ClientVeteranSkillLevel));
		return Recoil * GetProperRecoilSpread(Other);
	}
	Recoil = 1.0;
	Return Recoil * GetProperRecoilSpread(Other);
}

static function float GetBodyArmorDamageModifier(KFPlayerReplicationInfo KFPRI)
{
	local float ret;
	
	if ( KFPRI.ClientVeteranSkillLevel == 0 )
		ret = 1.0 / 2.0;
	if ( KFPRI.ClientVeteranSkillLevel == 1 )
		ret = 1.0 / 2.5;
	if ( KFPRI.ClientVeteranSkillLevel == 2 )
		ret = 1.0 / 3.0;
	if ( KFPRI.ClientVeteranSkillLevel == 3 )
		ret = 1.0 / 3.5;
	if ( KFPRI.ClientVeteranSkillLevel == 4 )
		ret = 1.0 / 4.0;
	if ( KFPRI.ClientVeteranSkillLevel == 5 )
		ret = 1.0 / 4.5;
	if ( KFPRI.ClientVeteranSkillLevel == 6 )
		ret = 1.0 / 5.0;
	if ( KFPRI.ClientVeteranSkillLevel == 7 )
		ret = 1.0 / 5.5;
	if ( KFPRI.ClientVeteranSkillLevel == 8 )
		ret = 1.0 / 6.0;
	if ( KFPRI.ClientVeteranSkillLevel > 8 )
		ret = 1.0 / 6.5;
		
	if ( KFGameType(KFPRI.Level.Game).bZedTimeActive )
	{
		ret *= KFPRI.Level.TimeDilation / 1.1;
	}

	return ret;
}

static function float GetWeldSpeedModifier(KFPlayerReplicationInfo KFPRI)
{
	if ( KFPRI.ClientVeteranSkillLevel == 0 )
		return 1.45;
	else if ( KFPRI.ClientVeteranSkillLevel == 1 )
		return 1.60;
	else if ( KFPRI.ClientVeteranSkillLevel == 2 )
		return 1.80;
	else if ( KFPRI.ClientVeteranSkillLevel == 3 )
		return 2.00;
	else if ( KFPRI.ClientVeteranSkillLevel == 4 )
		return 2.20;
	else if ( KFPRI.ClientVeteranSkillLevel == 5 )
		return 2.40;
	else if ( KFPRI.ClientVeteranSkillLevel == 6 )
		return 2.60;
	else if ( KFPRI.ClientVeteranSkillLevel == 7 )
		return 2.80;
	else if ( KFPRI.ClientVeteranSkillLevel == 8 )
		return 3.00;
	else if ( KFPRI.ClientVeteranSkillLevel > 8 )
		return 3.20;
}

static function int AddCarryMaxWeight(KFPlayerReplicationInfo KFPRI)
{
	local int ret;
	
	ret = 0;

	if ( KFPRI.ClientVeteranSkillLevel == 0 )
		ret = 3;
	else if ( KFPRI.ClientVeteranSkillLevel == 1 )
		ret = 4;
	else if ( KFPRI.ClientVeteranSkillLevel == 2 )
		ret = 5;
	else if ( KFPRI.ClientVeteranSkillLevel == 3 )
		ret = 6;
	else if ( KFPRI.ClientVeteranSkillLevel == 4 )
		ret = 8;
	else if ( KFPRI.ClientVeteranSkillLevel == 5 )
		ret = 10;
	else if ( KFPRI.ClientVeteranSkillLevel == 6 )
		ret = 12;
	else if ( KFPRI.ClientVeteranSkillLevel == 7 )
		ret = 14;
	else if ( KFPRI.ClientVeteranSkillLevel == 8 )
		ret = 17;
	else if ( KFPRI.ClientVeteranSkillLevel > 8 )
		ret = 20;
		
	return ret + Super.AddCarryMaxWeight(KFPRI);
}

static function int GetMaxArmor(KFPlayerReplicationInfo KFPRI)
{
	if ( KFPRI.ClientVeteranSkillLevel >= 10 )
		return 200;

	return Super.GetMaxArmor(KFPRI);
}

static function class<Grenade> GetNadeType(KFPlayerReplicationInfo KFPRI)
{
	return class'SupportAmmoNade';
}

static function string GetPickupShopName(KFPlayerReplicationInfo KFPRI, Class<Pickup> PickupClass, optional int FireModeNum)
{
	if ( PickupClass == class'Frag1Pickup' )
		return "Ammo Box";
	
	return Super.GetPickupShopName(KFPRI,PickupClass);
}

static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
	if ( Item == class'ThompsonPickup' || Item == class'SA80LSWPickup' || Item == class'PKMPickup' || Item == class'M249Pickup' || Item == class'BerettaPx4Pickup' ||
		Item == class'DualBerettaPx4Pickup' || Item == class'RPK47Pickup' || Item == class'AUG_A1MGPickup' )
	{
		return GetDefaultCostScaling(KFPRI.ClientVeteranSkillLevel) * GetProperCostScaling(Item);
	}
	return GetProperCostScaling(Item);
}

static function float GetAmmoCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
	return GetProperAmmoCostScaling(Item);
}

// Give Extra Items as default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
	super.AddDefaultInventory(KFPRI,P);
	
	if ( SRPlayerReplicationInfo(KFPRI).bRespawned )
		return;

	if ( KFPRI.ClientVeteranSkillLevel > 2 && KFPRI.ClientVeteranSkillLevel < 6 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.Thompson", GetCostScaling(KFPRI, class'ThompsonPickup'));

	if ( KFPRI.ClientVeteranSkillLevel > 5 && KFPRI.ClientVeteranSkillLevel < 9 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.SA80LSW", GetCostScaling(KFPRI, class'SA80LSWPickup'));

	if ( KFPRI.ClientVeteranSkillLevel > 8 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.M249Machinegun", GetCostScaling(KFPRI, class'M249Pickup'));
	
	SRPlayerReplicationInfo(KFPRI).bRespawned = true;
}

static function float GetMagCapacityMod(KFPlayerReplicationInfo KFPRI, KFWeapon Other)
{
	if( KFPRI.ClientVeteranSkillLevel > 9 && Thompson(Other) != none )
		return 2.0 * GetProperMagCapacity(Other);

	return GetProperMagCapacity(Other);
}

defaultproperties
{
    CustomLevelInfo="%r extra melee damage|%s faster melee attacks|20% faster melee movement|80% less damage from Bloat Bile|%l resistance to all damage|%d discount on Katana/Chainsaw|Spawn with a Chainsaw and Body Armor|Can't be grabbed by Clots|Up to 4 Zed-Time Extensions"
	NumRequirements=2
	PerkIndex=8
	BronzeIcon=Texture'SunriseHUD.Icons.Perk_Juggernaut_Bronze'
	SilverIcon=Texture'SunriseHUD.Icons.Perk_Juggernaut_Silver'
	GoldIcon=Texture'SunriseHUD.Icons.Perk_Juggernaut_Gold'
    OnHUDIcon=Texture'SunriseHUD.Icons.Perk_Juggernaut_red'
    OnHUDGoldIcon=Texture'SunriseHUD.Icons.Perk_Juggernaut_gold'
    VeterancyName="Juggernaut"
    Requirements(0)="Weld %x door hitpoints"
    Requirements(1)="Deal %x damage with machineguns"
    SRLevelEffects(0)="20% less recoil with machineguns|Can drop ammo boxes|20% extra machinegun ammo|45% faster welding/unwelding|2x better Body Armor|32% less damage from melee attacks|Can carry 18 weight blocks|50% discount on machineguns"
    SRLevelEffects(1)="25% less recoil with machineguns|Can drop ammo boxes|25% extra machinegun ammo|60% faster welding/unwelding|2.5x better Body Armor|34% less damage from melee attacks|Can carry 19 weight blocks|55% discount on machineguns"
    SRLevelEffects(2)="30% less recoil with machineguns|Can drop ammo boxes|30% extra machinegun ammo|80% faster welding/unwelding|3x better Body Armor|36% less damage from melee attacks|Can carry 6 ammo boxes|Can carry 20 weight blocks|60% discount on machineguns"
    SRLevelEffects(3)="35% less recoil with machineguns|Can drop ammo boxes|35% extra machinegun ammo|100% faster welding/unwelding|3.5x better Body Armor|38% less damage from melee attacks|Can carry 6 ammo boxes|Can carry 21 weight blocks|65% discount on machineguns|Spawn with a Thompson"
    SRLevelEffects(4)="40% less recoil with machineguns|Can drop ammo boxes|40% extra machinegun ammo|120% faster welding/unwelding|4x better Body Armor|40% less damage from melee attacks|Can carry 7 ammo boxes|Can carry 23 weight blocks|70% discount on machineguns|Spawn with a Thompson"
    SRLevelEffects(5)="45% less recoil with machineguns|Can drop ammo boxes|45% extra machinegun ammo|140% faster welding/unwelding|4.5x better Body Armor|42% less damage from melee attacks|Can carry 8 ammo boxes|Can carry 25 weight blocks|70% discount on machineguns|Spawn with a Thompson"
    SRLevelEffects(6)="50% less recoil with machineguns|Can drop ammo boxes|50% extra machinegun ammo|160% faster welding/unwelding|5x better Body Armor|44% less damage from melee attacks|Can carry 9 ammo boxes|Can carry 27 weight blocks|70% discount on machineguns|Spawn with a SA80LSW"
	SRLevelEffects(7)="55% less recoil with machineguns|Can drop ammo boxes|55% extra machinegun ammo|180% faster welding/unwelding|5.5x better Body Armor|46% less damage from melee attacks|Can carry 10 ammo boxes|Can carry 29 weight blocks|75% discount on machineguns|Spawn with a SA80LSW"
    SRLevelEffects(8)="60% less recoil with machineguns|Can drop ammo boxes|60% extra machinegun ammo|200% faster welding/unwelding|6x better Body Armor|48% less damage from melee attacks|Can carry 11 ammo boxes|Can carry 32 weight blocks|75% discount on machineguns|Spawn with a SA80LSW"
    SRLevelEffects(9)="65% less recoil with machineguns|Can drop ammo boxes|65% extra machinegun ammo|220% faster welding/unwelding|6.5x better Body Armor|50% less damage from melee attacks|Can carry 12 ammo boxes|Can carry 35 weight blocks|80% discount on machineguns|Spawn with an M249"
    SRLevelEffects(10)="65% less recoil with machineguns|Can drop ammo boxes|65% extra machinegun ammo|220% faster welding/unwelding|6.5x better Body Armor|50% less damage from melee attacks|Can carry 12 ammo boxes|Can carry 35 weight blocks|80% discount on machineguns|Spawn with an M249 and 100 armor|Elite abilities:|70% extra headshot damage with 9mm tactical|Regenerates health|Weapon Mastery - Thompson has doubled mag and ammo"
}